package com.cssl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cssl.pojo.SocCity;
import com.cssl.service.SocCityService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class CityController {
    @Resource
    private SocCityService service;

    @GetMapping("/cx")
    public List<SocCity> cx(){
        return service.list();
    }

    @GetMapping("/getOne")
    public SocCity get(Integer id){
        return service.getById(id);
    }
    @GetMapping("/page")
    public IPage<SocCity> page(Integer pageIndex,Integer pageSize){
        if (pageIndex == null){
            pageIndex=1;
        }
        if (pageSize==null){
            pageSize=5;
        }
        IPage<SocCity> pages= service.pageCx(new Page<SocCity>(pageIndex,pageSize),new QueryWrapper<SocCity>().eq("is_deleted",0));
        return pages;
    }

}
